package com.gateway.config;

import com.gateway.filter.CustomGatewayFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.GatewayFilterSpec;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.cloud.gateway.route.builder.UriSpec;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Function;

@Configuration
public class GatewayConfig {
//    @Bean
//    public RouteLocator customRouteLocator(RouteLocatorBuilder builder){
//        return builder.routes()
//                .route("goods",
//                        r -> r.path("/goods/**")
//                                .filters(new Function<GatewayFilterSpec, UriSpec>() {
//                                    @Override
//                                    public UriSpec apply(GatewayFilterSpec gatewayFilterSpec) {
//                                        return gatewayFilterSpec.filter(new CustomGatewayFilter());
//                                    }
//                                })
//                                .uri("http://localhost:10001"))
//                .build();
//    }
}
